package com.wenx.v3system.modular.platform.domain.dto;

import com.wenx.base.domain.BaseDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 平台用户DTO
 * 基于简化权限模型
 * 
 * @author wenx
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "平台用户信息")
public class PlatformUserDto extends BaseDto {

    @NotBlank(message = "用户名不能为空")
    @Size(max = 50, message = "用户名长度不能超过50个字符")
    @Schema(description = "用户名", example = "platform_admin")
    private String username;

    @Size(min = 6, max = 100, message = "密码长度必须在6-100个字符之间")
    @Schema(description = "密码", example = "123456")
    private String password;

    @NotBlank(message = "真实姓名不能为空")
    @Size(max = 50, message = "真实姓名长度不能超过50个字符")
    @Schema(description = "真实姓名", example = "平台管理员")
    private String realName;

    @Email(message = "邮箱格式不正确")
    @Schema(description = "邮箱", example = "admin@v3cloud.com")
    private String email;

    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    @Schema(description = "手机号", example = "13800138000")
    private String phone;

    @Schema(description = "头像URL", example = "/avatar/admin.jpg")
    private String avatar;

    @Schema(description = "用户类型", example = "platform")
    private String userType;

    @Schema(description = "用户状态：1-正常，2-锁定，0-禁用", example = "1")
    private Integer status;

    @Schema(description = "最后登录时间")
    private LocalDateTime lastLoginTime;

    @Schema(description = "最后登录IP", example = "192.168.1.100")
    private String lastLoginIp;

    @Schema(description = "登录次数", example = "1247")
    private Integer loginCount;

    @Schema(description = "密码过期时间")
    private LocalDateTime passwordExpireTime;

    @Schema(description = "是否必须修改密码", example = "false")
    private Boolean mustChangePassword;

    @Schema(description = "是否启用双因子认证", example = "false")
    private Boolean twoFactorEnabled;

    @Schema(description = "用户设置（JSON格式）")
    private String settings;

    // 扩展字段（从关联表查询得到）
    @Schema(description = "角色编码列表")
    private List<String> roleCodes;

    @Schema(description = "角色ID列表（用于接收前端传递的角色数据）")
    private List<String> roleIds;

    @Schema(description = "角色名称列表（兼容性保留）")
    private List<String> roleNames;

    @Schema(description = "权限列表")
    private List<String> permissions;

    @Schema(description = "菜单编码列表")
    private List<String> menuCodes;

    @Schema(description = "可访问的租户列表")
    private List<String> accessibleTenants;

    @Schema(description = "是否为超级管理员", example = "false")
    private Boolean isSuperAdmin;
}